import 'package:flutter/cupertino.dart';
import 'package:flutter_deer/index/iview/capital_comparison_list_iview.dart';
import 'package:flutter_deer/index/models/capital_comparison_entity.dart';
import 'package:flutter_deer/index/models/com_code_entity.dart';
import 'package:flutter_deer/mvp/base_page_presenter.dart';
import 'package:flutter_deer/net/base_entity.dart';
import 'package:flutter_deer/net/net.dart';
import 'package:flutter_deer/res/constant.dart';

class CapitalComparisonListPagePresenter
    extends BasePagePresenter<CapitalComparisonListIMvpView> {
  CapitalComparisonListPagePresenter();

  @override
  void initState() {}

  Future<dynamic> getCapitalComparisonList(String? fiscalYear, String? type) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['fiscal_year'] = fiscalYear;
      params['page_size'] = Constant.pageSize;
      params['current'] = 1;
      String url;
      switch (type) {
        case '1':
          url = HttpApi.capitalComparisonPageList; 
          break;
        case '2':
          url = HttpApi.capitalComparisonPageGovList; 
          break;
        case '3':
          url = HttpApi.capitalComparisonPageFuncList; 
          break;
        case '4':
          url = HttpApi.capitalComparisonPageAgencyList; 
          break;
        default:
           url = HttpApi.capitalComparisonPageFundTypeList; 
      }
      asyncRequestNetwork<BaseEntity<CapitalComparisonPageEntity>>(Method.get,
          url: url,
          queryParameters: params, onSuccess: (data) {
        view.setCapitalComparisonPage(data!.data);
      }, onError: (code, msg) {});
    });
  }

  Future<dynamic> getMoreCapitalList(String? fiscalYear, int? pageNo, String? type) async {
    WidgetsBinding.instance.addPostFrameCallback((_) {
      final Map<String, dynamic> params = <String, dynamic>{};
      params['fiscal_year'] = fiscalYear;
      params['page_size'] = Constant.pageSize;
      params['current'] = pageNo;
      String url;
      switch (type) {
        case '1':
          url = HttpApi.capitalComparisonPageList; 
          break;
        case '2':
          url = HttpApi.capitalComparisonPageGovList; 
          break;
        case '3':
          url = HttpApi.capitalComparisonPageFuncList; 
          break;
        case '4':
          url = HttpApi.capitalComparisonPageAgencyList; 
          break;
        default:
           url = HttpApi.capitalComparisonPageFundTypeList; 
      }
      asyncRequestNetwork<BaseEntity<CapitalComparisonPageEntity>>(Method.get,
          url: url,
          queryParameters: params, onSuccess: (data) {
        view.setCapitalComparisonPage(data!.data);
      }, onError: (code, msg) {});
    });
  }

  // Future<dynamic> getFundTypeList(String fund_type_name) async {
  //   WidgetsBinding.instance.addPostFrameCallback((_) {
  //     final Map<String, String> params = <String, String>{};
  //     params['fund_type_name'] = fund_type_name;
  //     asyncRequestNetwork<BaseEntity<List<CodeMapEntity>>>(Method.get,
  //         url: HttpApi.getFundTypeMapList,
  //         queryParameters: params, onSuccess: (data) {
  //       view.setFundTypeListPage(data!.data);
  //     }, onError: (code, msg) {
  //       print('onErrorxxxxxxxxxxxxxxxxsdd');
  //     });
  //   });
  // }


  // Future<dynamic> getDepBgtEcoList(String? dep_bgt_eco_name) async {
  //   WidgetsBinding.instance.addPostFrameCallback((_) {
  //     final Map<String, dynamic> params = <String, dynamic>{};
  //     params['dep_bgt_eco_name'] = dep_bgt_eco_name;
  //     asyncRequestNetwork<BaseEntity<dynamic>>(Method.get,
  //         url: HttpApi.getDepBgtEcoMapList,
  //         queryParameters: params, onSuccess: (data) {
  //       view.setDepBgtEcoListPage(data!.data as List);
  //     }, onError: (code, msg) {});
  //   });
  // }

  // Future<dynamic> getGovBgtEcoList(String? gov_bgt_eco_name) async {
  //   WidgetsBinding.instance.addPostFrameCallback((_) {
  //     final Map<String, dynamic> params = <String, dynamic>{};
  //     params['gov_bgt_eco_name'] = gov_bgt_eco_name;
  //     asyncRequestNetwork<BaseEntity<dynamic>>(Method.get,
  //         url: HttpApi.getGovBgtEcoMapList,
  //         queryParameters: params, onSuccess: (data) {
  //       view.setGovBgtEcoListPage(data!.data as List);
  //     }, onError: (code, msg) {});
  //   });
  // }

  // Future<dynamic> getExpFuncList(String? exp_func_name) async {
  //   WidgetsBinding.instance.addPostFrameCallback((_) {
  //     final Map<String, dynamic> params = <String, dynamic>{};
  //     params['exp_func_name'] = exp_func_name;

  //     asyncRequestNetwork<BaseEntity<dynamic>>(Method.get,
  //         url: HttpApi.getExpFuncMapList,
  //         queryParameters: params, onSuccess: (data) {
  //       view.setExpFuncListPage(data!.data as List);
  //     }, onError: (code, msg) {});
  //   });
  // }
}
